<?php

class openapi_utils_image {

    public static function getimgbyid($imageid) {
        if (empty($imageid)) {
            return null;
        }
        $imagemdl = app::get('image')->model('image');
        $url = $imagemdl->getList('*', array(
            'image_id' => $imageid
        ));
        return $url[0];
    }

    public static function get_img_url($image_id, $size) {
        $url = cellphone_image_storager::image_path($image_id, $size);
        if (empty($url)) {
            $imageDefault = app::get('cellphone')->getConf('image.set');
            $url = cellphone_image_storager::image_path($imageDefault[strtoupper($size)]['default_image']);
        }
        return $url;
    }
}